package controller;

import org.junit.Test;
import pojo.Room;
import service.RoomService;
import service.RoomServiceImpl;
import service.RoomService;
import service.RoomServiceImpl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;


public class RoomController {
    private RoomService service = new RoomServiceImpl();
    /*
        查询所有房间信息
     */
    @Test
    public void findAll() {
        ArrayList<Room> list = service.findAll();
        for(Room room : list) {
            System.out.println(room);
        }
    }

    /*
        条件查询，根据id查询房间信息
     */
    @Test
    public void findByroomId() {
        Room room = service.findById(204);
        System.out.println(room);
    }

    /*
        添加房间信息
     */
    @Test
    public void insert() {
        Room room = new Room(204,"男",4,new BigDecimal(50),2,new BigDecimal(100));
        int result = service.insert(room);

        if(result!=0) {
            System.out.println("添加成功");
        }else {
            System.out.println("添加失败");
        }
    }

    /*
        修改房间信息
     */
    @Test
    public void update() {
        Room room = service.findById(100006);
        room.setSex("女");

        int result = service.update(room);

        if(result != 0) {
            System.out.println("修改成功");
        }else {
            System.out.println("修改失败");
        }
    }

    /*
        删除房间信息
     */
    @Test
    public void delete() {
        int result = service.delete(service.findById(204));

        if(result != 0) {
            System.out.println("删除成功");
        }else {
            System.out.println("删除失败");
        }
    }
}
